//
//  nightTableViewCell.m
//  soccer
//
//  Created by 上官千城 on 15/9/2.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "nightTableViewCell.h"

@implementation nightTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //        [self createSubViews];
    }
    return self;
    
}


-(void)createSubViews {
    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        //    夜间模式
        self.backgroundColor=[UIColor lightGrayColor];
        
        
    } else {
        
        self.backgroundColor=[UIColor whiteColor];
        
        
    }
    
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(changeNight:) name:@"changeNight" object:nil];
    
    
}


-(void)changeNight:(NSNotification *)notification {
    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        self.backgroundColor = [UIColor lightGrayColor];
    } else {
        
        self.backgroundColor = [UIColor whiteColor];
        
    }
    
}

- (void)awakeFromNib {
    // Initialization code
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
